﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Demos.DesignPatterns._23_访问者模式
{
    /// <summary>
    /// 收据打印机
    /// </summary>
    public class ReceiptPrinter : IVisitor
    {
        /// <summary>
        /// 访问普通商品
        /// </summary>
        /// <param name="product"></param>
        public void Visit(RegularProduct product)
        {
            Console.WriteLine($"普通商品：{product.Name} x{product.Quantity} @ {product.Price:C} = {product.Price * product.Quantity:C}");
        }
        /// <summary>
        /// 访问折扣商品
        /// </summary>
        /// <param name="product"></param>
        public void Visit(DiscountedProduct product)
        {
            Console.WriteLine($"折扣商品：{product.Name} x{product.Quantity} (原价:{product.OriginalPrice:C}, 折后价:{product.DiscountedPrice:C}) = {product.DiscountedPrice * product.Quantity:C}");
        }
        /// <summary>
        /// 访问礼品卡
        /// </summary>
        /// <param name="giftCard"></param>
        public void Visit(GiftCard giftCard)
        {
            Console.WriteLine($"礼品卡：{giftCard.Name} - 金额: {giftCard.Amount:C}");
        }
        /// <summary>
        /// 计算总价
        /// </summary>
        /// <param name="product1"></param>
        /// <param name="product2"></param>
        public void CalcPrice(RegularProduct product1, DiscountedProduct product2)
        {
            Console.WriteLine(  "===============计算商品总价-------------------");
        }

    }
}
